﻿using MyUAMS.BLL;
using MyUAMS.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserWork_AssetBR : System.Web.UI.Page
{
    WorkServer assetSrv = new WorkServer();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }
    protected string GetCategoryName(object categoryId)
    {
        if (categoryId == null) return string.Empty; // 防止空值

        int id = Convert.ToInt32(categoryId); // 将对象转换为整数

        using (var context = new DataClasses1DataContext())
        {
            // 查询类别名称
            var category = context.AssetType_Table.SingleOrDefault(c => c.Tid == id);
            return category != null ? category.Tname : "未知类别"; // 返回类别名称或默认值
        }
    }
    protected void Bind()
    {
        var products = assetSrv.GetAllProduct();
        if (products.Count() == 0)
        {
            lblProErr.Text = "校园还未拥有资产,请添加！";
        }
        else
        {
            lblProErr.Text = " ";
        }
        dgvAsset.DataSource = assetSrv.GetAllProduct();
        dgvAsset.DataBind();
    }
}